<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN" >
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Insert title here</title>
		<style type="text/css">
			li {
				float: left;
				margin-left: 20px;
			}
		</style>

		<link rel="stylesheet" href="js/bootstarp-3.3.7/css/bootstrap.min.css" />
		<script src="js/jquery/jquery-3.2.1.min.js" type="text/javascript" charset="UTF-8"></script>
		<script src="js/bootstarp-3.3.7/js/bootstrap.min.js" type="text/javascript" charset="UTF-8"></script>
		<link rel="stylesheet" type="text/css" href="js/bootstarp-table-1.11.1/bootstrap-table.min.css" />
		<script src="js/bootstarp-table-1.11.1/bootstrap-table.min.js" type="text/javascript" charset="UTF-8"></script>
		<script src="js/bootstarp-table-1.11.1/bootstrap-table-zh-CN.min.js"></script>
		<script>
			$(function() { //, headers: { 'x-requested-with': 'XMLHttpRequest' }
				$.ajaxSetup({
					crossDomain: true,
					xhrFields: {
						withCredentials: true
					}
				});
			});
		</script>
		<script type="text/javascript">
			$(function() {
				//查询表单刷新  
				$("#cx").click(function() {
					$("#table1").bootstrapTable('refresh');
				});

				$("#table1").bootstrapTable({
					type: "post",
					url: "http://127.0.0.1:8099/dm/cxqbdm",
					pagesize: "3",
					queryParams: queryparam,
					columns: [{
						field: "id",
						title: "编号",
						align: "center",
					}, {
						field: "true_name",
						title: "姓名",
						align: "center",
					}, {
						field: "uid",
						title: "用户",
						align: "center",
						visible: false
					}, {
						field: "sexs",
						title: "性别",
						align: "center",
					}, {
						field: "age",
						title: "年龄",
						align: "center",
					}, {
						field: "user_name",
						title: "电话",
						align: "center",
					}, {
						field: "department_id",
						title: "科室",
						align: "center",
						visible: false
					}, {
						field: "department_name",
						title: "科室",
						align: "center",
					}, {
						field: "title",
						title: "职务",
						align: "center",
					}, {
						field: "create_time",
						title: "入职日期",
						align: "center",
						visible: false
					}, {
						title: ' 禁 用 ',
						align: 'center',
						formatter: function(value, row, index) {
							return '<button type="button" va class="btn btn-info" onclick="rrr(' + row.uid + ')" data-toggle="modal" data-target="#cctv33"><span class="glyphicon glyphicon-ok"></span>';
						}
					}, {
						title: ' 编 辑 ',
						align: 'center',
						formatter: function(value, row, index) {
							return '<button type="button" va class="btn btn-info" onclick="xg(' + row.id + ',' + index + ')" data-toggle="modal" data-target="#cctv33"><span class="glyphicon glyphicon-ok"></span>';
						}
					}]
				})

				$.getJSON("http://127.0.0.1:8099/dm/cxqbdm", function(data) {
					for(var i = 0; i < data.length; i++) {
						$("#mhcx,#true_name").append("<option value='" + data[i].true_name + "'>" + data[i].true_name + "</option>")
					}
				})
				
				
				$.getJSON("http://127.0.0.1:8099/dm/xlkcx", function(data) {
				for(var i = 0; i < data.length; i++) {
					$("#zw,#title,#zhiwu").append("<option value='" + data[i].id + "'>" + data[i].title + "</option>")
				}
			});

			$.getJSON("http://127.0.0.1:8099/dm/xxllkkcx", function(data) {
				for(var i = 0; i < data.length; i++) {
					$("#ks,#department_name,#kesi1").append("<option value='" + data[i].did + "'>" + data[i].department_name + "</option>")
				}
			});

			$.getJSON("http://127.0.0.1:8099/dm/x", function(data) {
				for(var i = 0; i < data.length; i++) {
					$("#jb,#title_level,#jibie").append("<option value='" + data[i].rid + "'>" + data[i].title_level + "</option>")
				}
			});
			})

			function queryparam() {
				return {
					true_name: $("#mhcx").val()
				};

			}

			function rrr(uid, index) {
				$.ajax({
					data: "uid=" + uid,
					type: "post",
					url: "http://127.0.0.1:8099/dm/xgdm",
					dataType: "json",
					success: function(data) {
						$("#table1").bootstrapTable('refresh');
						$("#table2").bootstrapTable('refresh');
					}
				});
			}

			function xg(id, index) {
				$("#cctv2").modal('show');
				$("#zhiwu").val(0);
				$("#jibie").val(0);
				$("#kesi1").val(0);

				$.ajax({

					type: "post",
					url: "http://127.0.0.1:8099/dm/upcx",
					data: "id=" + id,
					success: function(data) {
						$("#uid").val(data.id);
						$("#xxmm").val(data.xxmm);
						if(data.sex == 1) {
							$("#sex1").val(1);
						} else {
							$("#sex1").val(2);
						}

						$("#user_name1").val(data.sjh);
						$("#age1").val(data.age);
						$("#kesi1").val(data.did);
						$("#zhiwu").val(data.id);
						$("#jibie").val(data.rid);
						$("#strong").val(data.strong);
						$("#introduction").val(data.introduction);
					}
				});

			}

			function huifu(uid, index) {
				$.ajax({
					data: "uid=" + uid,
					type: "post",
					url: "http://127.0.0.1:8099/dm/hfxgdm",
					dataType: "json",
					success: function(data) {

						$("#table2").bootstrapTable('refresh');
						$("#table1").bootstrapTable('refresh');
					}
				});
			}

			function jy() {
				$("#table2").bootstrapTable({
					type: "post",
					url: "http://127.0.0.1:8099/dm/jycxqb",
					pagesize: "3",
					queryParams: queryparam,
					columns: [{
						field: "id",
						title: "编号",
						align: "center",
					}, {
						field: "true_name",
						title: "姓名",
						align: "center",
					}, {
						field: "uid",
						title: "用户",
						align: "center",
						visible: false
					}, {
						field: "sexs",
						title: "性别",
						align: "center",
					}, {
						field: "age",
						title: "年龄",
						align: "center",
					}, {
						field: "user_name",
						title: "电话",
						align: "center",
					}, {
						field: "department_name",
						title: "科室",
						align: "center",
					}, {
						field: "title",
						title: "职务",
						align: "center",
					}, {
						field: "start_time_this_week",
						title: "入职日期",
						align: "center",
						visible: false
					}, {
						title: ' 恢 复 ',
						align: 'center',
						formatter: function(value, row, index) {
							return '<button type="button" class="btn btn-info" onclick="huifu(' + row.uid + ')" data-toggle="modal" data-target="#cctv33"><span class="glyphicon glyphicon-ok"></span>';
						}
					}]
				})

			}

			

			function aaa() {
				$.ajax({
					type: "post",
					url: "http://127.0.0.1:8099/dm/doctoradd",
					data: $("#fff").serialize(),
					success: function(data) {
						$("#cctv").modal("hide");
						$("#table1").bootstrapTable("refresh");

					}
				});
			}

			function tianjiaBTN() {
				var addsj = new RegExp(/^1[3|4|5|8|7][0-9]\d{8}$/)
				var phnoe = document.getElementById("user_name").value;
				if(addsj.test(phnoe)) {
					aaa();
				} else {
					alert("请输入正确的手机号")
				}

			}

			function xxgg() {

				$.ajax({
					type: "post",
					url: "http://127.0.0.1:8099/dm/galup",
					dataType: "json",
					data: $("#xiugai").serialize(),
					success: function(data) {
						alert($("#sex1").val())
						$("#cctv2").modal("hide");
						$("#table1").bootstrapTable("refresh");
					}
				});
			}
		</script>

	</head>

	<body>
		<div class="modal fade" id="" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">

		</div>
		<br />

		<div class="modal fade" id="myModal" tabindex="3" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog modal-lg" style="height: 300px;">
				<div class="modal-content">
					<div class="modal-header">

						<h4 class="modal-title" id="myModalLabel"></h4>
					</div>
					
					
					
					<div class="modal-body">

						<table id="table2"></table>

						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
							<button type="button" class="btn btn-primary" id="btu">提交更改</button>
						</div>
					</div>
				</div>
			</div>
		</div>
		

		<!-- Modal -->
		<div class="modal fade" id="cctv" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title" id="myModalLabel">添加</h4>
					</div>
					<form id="fff">
						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon" id="basic-addon1">姓名</span>
								<input type="text" class="form-control" placeholder="请填写姓名" id="true_name" name="xm" aria-describedby="basic-addon1">
							</div>
						</div>

						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon" id="basic-addon1">科室</span>
								<select class="form-control" id="ks" name="ks">
									<option value="">请选择科室</option>
								</select>
							</div>
						</div>

						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon" id="basic-addon1">级别</span>
								<select class="form-control" id="jb" name="jb">
									<option value="0">请选择级别</option>
								</select>
							</div>
						</div>

						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon" id="basic-addon1">手机号</span>
								<input type="text" class="form-control" placeholder="请输入手机号" id="user_name" name="user_name" aria-describedby="basic-addon1">
							</div>
						</div>

						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon" id="basic-addon1">年龄</span>
								<input type="text" class="form-control" placeholder="请填写年龄" id="age" name="age" aria-describedby="basic-addon1">
							</div>
						</div>

						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon" id="basic-addon1">职务</span>
								<select class="form-control" id="zw" name="zw">
									<option value="rid">请选择职务</option>
								</select>
							</div>
						</div>
					</form>

					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button type="button" onclick="tianjiaBTN()" class="btn btn-primary">添加</button>
					</div>
				</div>
			</div>
		</div>
		</div>

		<form id="xiugai">
			<div class="modal fade" id="cctv2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
				<div class="modal-dialog" role="document">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
							<h4 class="modal-title" id="myModalLabel">
</h4>
						</div>

						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon" id="basic-addon1">姓名</span>
								<input type="hidden" id="uid" name="uid" />
								<input type="text" class="form-control" id="xxmm" name="true_name" aria-describedby="basic-addon1">
							</div>
						</div>

						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon" id="basic-addon1">性别</span>
								<select class="form-control" id="sex1" name="sex">
									<option value="1">男</option>
									<option value="2">女</option>
								</select>
							</div>
						</div>

						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon">手机号</span>
								<input type="text" disabled style="cursor: not-allowed" id="user_name1" name="user_name" />
							</div>
						</div>

						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon">年龄</span>
								<input type="text" class="form-control" id="age1" name="age" aria-describedby="basic-addon1">
							</div>
						</div>

						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon">科室</span>
								<select class="form-control" id="kesi1" name="kesi">
									<option value="0"></option>
								</select>
							</div>
						</div>

						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon" id="basic-addon1">级别</span>
								<select class="form-control" id="jibie" name="title_level">
									<option value="0">请选择级别</option>
								</select>
							</div>
						</div>

						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon" id="basic-addon1">职务</span>
								<select class="form-control" id="zhiwu" name="zhiwu">
									<option value="0">请选择职务</option>
								</select>
							</div>
						</div>

						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon" id="basic-addon1">医生擅长</span>
								<input type="text" class="form-control" placeholder="" id="strong" name="strong" aria-describedby="basic-addon1">
							</div>
						</div>

						<div class="modal-body">
							<div class="input-group">
								<span class="input-group-addon" id="basic-addon1">医生介绍</span>
								<input type="text" class="form-control" placeholder="" id="introduction" name="introduction" aria-describedby="basic-addon1">
							</div>
						</div>
		</form>

		<div class="modal-footer">
			<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
			<button type="button" class="btn btn-primary" onclick="xxgg()">Save changes</button>
		</div>
		</div>
		</div>
		</div>
		</div>

		<table>
			<tr>
				<td><input class="form-control" type="text" id="mhcx" name="true_name" /></td>
				<td><button type="button" class="btn btn-primary" id="cx">查询</button></td>

				<td width="1000"></td>
				<td width="150">
					<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal" onclick="jy()">已禁用人</button>

				</td>

				<td><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#cctv">添加医生</button></td>
			</tr>
		</table>
		
		<br />

		</div>

		<table id="table1"></table>

	</body>

</html>